$(function(){
    var price = $('.order-original-price').text();
    var count = $('.order-num-box .count').text();
    var coupon = $('.coupon-price .dolor').text();

    var tech = price*count;
    var total_price = tech-coupon;
    $('.order-price-total .order-total-price.price').text(tech);
    $('.total-prices-price .dolor').text(total_price);

    if (total_price>0){
        $('.total-prices-price .dolor').text(total_price);
    }
    else{
        $('.total-prices-price .dolor').text('0');
    }

    $('.order-num-box button.add').click(function () {
        count++;
        change_dolor(count);
    });

    $('.order-num-box button.reduce').click(function () {
        if(count>1){
            count--;
            change_dolor(count);
        }
        else{
            count = 1;
            change_dolor(count);
        }
    });

    function change_dolor(count){
        var tech = price*count;
        var total_price = tech-coupon;
        $('.order-price-total .order-total-price.price').text(tech);
        $('.order-num-box .count').text(count);
        if (total_price>0){
            $('.total-prices-price .dolor').text(total_price);
        }
        else{
            $('.total-prices-price .dolor').text('0');
        }

    }

});
